import java.lang.reflect.Array;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2022-08-01
 * Time: 0:09
 */
public class Test {
    public static void printArray(int[] arr, int len) {
        for (int i = 0; i < len; i++) {
            System.out.print(arr[i] +" ");
        }
    }
    public static void main(String[] args) {
        // 实现一个方法 printArray, 以数组为参数, 循环访问数组中的每个元素, 打印每个元素的值.
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        int len = arr.length;
        printArray(arr, len);
    }
    public static void main8(String[] args) {
        // 创建一个 int 类型的数组, 元素个数为 100, 并把每个元素依次设置为 1 - 100
        int[] arr = new int[100];

        for (int i = 0; i < 100; i++) {
            arr[i] = i+1;
        }
        for (int data:
             arr) {
            System.out.println(data);
        }
    }
    public static void hanoi(int n,char pos1,char pos2,char pos3) {
        if(n == 1) {
            move(pos1,pos3);
            return;
        }
        hanoi(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanoi(n-1,pos2,pos1,pos3);
    }
    public static void move(char pos1,char pos2) {
        System.out.print(pos1+"->"+pos2+" ");
    }
    public static void main7(String[] args) {
        // 递归求解汉诺塔问题
        char a = 'A';
        char b = 'B';
        char c = 'C';
        hanoi(3, 'A', 'B', 'C');
    }
    public static int fibonacci(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        return fibonacci(n - 1) + fibonacci(n - 2);
    }
    public static void main6(String[] args) {
        // 递归求斐波那契数列的第 N 项
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        System.out.println(fibonacci(n));
    }
    public static int numberAdd(int n) {
        if (n < 10) {
            return n;
        }
        return numberAdd(n%10) + numberAdd(n/10);
    }
    public static void main5(String[] args) {
        //写一个递归方法，输入一个非负整数，返回组成它的数字之和
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        System.out.println(numberAdd(n));
    }
    public static void printNumber(int n) {
        if (n != 0) {
            printNumber(n / 10);
            System.out.print(n%10+" ");
        }
    }
    public static void main4(String[] args) {
        // 按顺序打印一个数字的每一位(例如 1234 打印出 1 2 3 4) （递归）\
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        printNumber(n);
    }

    public static int add(int n) {
        if(n == 1) {
            return 1;
        }
        return n+add(n-1);
    }
    public static void main3(String[] args) {
        // 递归求 1 + 2 + 3 + ... + 10
        Scanner in = new Scanner(System.in);
        System.out.println(add(10));
    }
    public static int factorial(int n) {
        if (n == 1) {
            return 1;
        }
        return n*(n-1);
    }
    public static void main2(String[] args) {
        //递归求 N 的阶乘
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        System.out.println(factorial(n));
    }

    public static void print(int a) {
        if (a != 0) {
            print(a / 10);
            System.out.println(a % 10);
        }
    }
    public static void main1(String[] args) {
        //
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        print(a);
    }
}


